package test.h0814;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author 不知名帅哥
 * @version 1.0
 * @description 虚拟理财游戏
 * @date 2024/8/14 15:28
 */
public class Main5 {

    static int[] ans;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int productNum = sc.nextInt();
        int totalAmount = sc.nextInt();
        int wrongs = sc.nextInt(); //可接受的总风险

        int[] rates = new int[productNum];
        for (int i = 0; i < productNum; i++) {
            rates[i] = sc.nextInt();
        }
        int[] risks = new int[productNum];
        for (int i = 0; i < productNum; i++) {
            risks[i] = sc.nextInt();
        }
        int[] invests = new int[productNum];
        for (int i = 0; i < productNum; i++) {
            invests[i] = sc.nextInt();
        }
        getRes(rates, risks, invests, totalAmount, wrongs);
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < ans.length; i++) {
            builder.append(ans[i]);
            if (i==ans.length-1){
                continue;
            }
            builder.append(" ");
        }
        System.out.println(builder.toString());
    }

    private static void getRes(int[] rates, int[] risks, int[] invests, int totalAmount, int wrongs) {
        int n = rates.length;
        ans = new int[n];
        int sum = 0;
        int a, b = 0;
        //最多可以投资两个，所以用双层for循环
        for (int i = 0; i < n; i++) {
            if (risks[i] > wrongs || invests[i] > totalAmount) continue; //非法
            a = invests[i] * rates[i];
            int tempInvestJ = totalAmount - invests[i]; //剩余投资金额

            for (int j = 0; j < n; j++) {
                if (i == j || risks[i] + risks[j] > wrongs) { //如果风险过大，重置结果
                    if (a > sum) {
                        sum = a;
                        ans = new int[n];
                        ans[i] = invests[i];
                    }
                    continue;
                }
                if (invests[j] > tempInvestJ) {
                    b = tempInvestJ * rates[j];
                } else {
                    b = invests[j] * rates[j];
                }

                if (a + b > sum) {
                    sum = a + b;
                    ans = new int[n];
                    ans[i] = invests[i];
                    ans[j] = Math.min(invests[j], tempInvestJ);
                }
            }
        }
    }
}
